﻿using System;
using log4net;
using Metozis.Model;
using Metozis.Repo;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;

namespace Metozis.Facade
{
    [TestClass]
    public class OrderFacadeTests
    {
        [TestMethod]
        public void GetOrderByInvoiceIdTest()
        {
            var log = MockRepository.GenerateStub<ILog>();

            var invoiceRepo = MockRepository.GenerateStub<IReceipientInvoiceRepo>();
            invoiceRepo.Expect(item => item.GetInvoiceById(1)).Return(new ReceipientInvoice {Id = 1, ProductId = 1});

            var productRepo = MockRepository.GenerateStub<IProductRepo>();
            productRepo.Expect(item => item.GetProductById(1)).Return(new Product{Id=1,Name = "a"});

            IOrderFacade facade = new OrderFacade(log, invoiceRepo,productRepo);

            Order order = facade.GetOrderByInvoiceId(1);

            Assert.AreEqual(order.InvoiceId, 1);
            Assert.AreEqual(order.ProductName, "a");
        }
    }
}
